﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace FileFilter
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            string output = string.Empty;
            int counter = 0;
            System.IO.StreamReader file =
                new System.IO.StreamReader(@"D:\log\log\5c53c6f2-5f5a-4b7f-b9a3-783a1713f603application.txt");

            Dictionary<string, int> dict = new Dictionary<string, int>();

            while ((line = file.ReadLine()) != null)
            {
                string[] stringArray = line.Split(' ');
                string path = stringArray[stringArray.Length - 2];
                if(dict.ContainsKey(path))
                    dict[path]++;
                else
                {
                    dict.Add(path,1);
                }

                counter++;
            }
            //linq sort by key
            var sortedDict = from entry in dict orderby entry.Value ascending select entry;

            System.Diagnostics.Trace.WriteLine("========================================================");
            // sort dict by key
            foreach (KeyValuePair<string, int> item in dict.OrderBy(key => key.Value))
            {
                // do something with item.Key and item.Value
                System.Diagnostics.Trace.WriteLine(item.Key + " " + item.Value);
            }

            System.Diagnostics.Trace.WriteLine("========================================================");

            file.Close();

        }
    }
}
